package com.zdsoft.blp.gongyong.upLoad;


import org.kobjects.base64.Base64;
import org.xutils.x;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * Created by pc on 2016/9/13.
 */
public class EncodeBase64ToString {

    public static String toString(String path){
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(path);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int count = 0;
            while ((count = fis.read(buffer)) >= 0) {
                baos.write(buffer, 0, count);
            }
            //进行Base64编码
            String uploadBuffer = new String(Base64.encode(baos.toByteArray()));
            return uploadBuffer;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
